#!/bin/sh
# Init script for all devices which store rootfs in RAM
# Not run on devices which use simpleramfs

log()
{
  echo "$*" >&2
}

mount -t devtmpfs none /dev
exec >/dev/kmsg 2>&1

echo "---- initramfs ('$0')"
mount -t proc none /proc && log "mounted /proc"
mount -t tmpfs none /tmp && log "mounted /tmp"
mount -t sysfs none /sys && log "mounted /sys"
mkdir /dev/pts /dev/shm
mount -t devpts none /dev/pts && log "mounted /dev/pts"
mount -t tmpfs none /dev/shm && log "mounted /dev/shm"

# pass in paths for $PLATFORM and $DEBUG
preinit "/etc/platform" "/tmp/DEBUG"

if is-windcharger; then
  #We want to limit RSS to be around 30M, however, ulimit -m
  #is not working for linux 2.6.30+.
  #There is no accurate, corresponding virtual memory metric for
  #RSS 30M, the number below is from estimate.
  ulimit -v 40960
fi

exec /sbin/init $* </dev/console >/dev/console 2>&1
